<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/2 0002
 * Time: 11:32
 */

namespace app\index\controller;


use think\Controller;

class Room extends Controller
{
    public function index(){
        $id = input("id");
        $title = db("title")->where("pid",0)->select();
        $this_title = db("title")->where("action","room")->find();
        $room_o = db("room")->where("pid",0)->select();
        if(empty($id)){
            $room_1 = db("room")->where("pid","neq",0)->order("id desc")->paginate(6);
        }else{
            $room_1 = db("room")->where("pid",$id)->order("id desc")->paginate(6);
            $this->assign("id",$id);
        }
        $this->assign([
            "action"=>"room",
            "title" => $title,
            "this_title" => $this_title,
            "room_o" => $room_o,
            "room_1" => $room_1
        ]);
        return view("index");
    }
    public function content(){
        $id = input("id");
        $room = db("room")->where("id",$id)->find();
        $this->assign("room",$room);
        $title = db("title")->where("pid",0)->select();
        $this->assign([
            "action"=>"room",
            "title" => $title,
        ]);
        return view("content");
    }
}